<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML>
<html>
<head>
<base href="<%=basePath%>">

<title>My JSP 'index.jsp' starting page</title>
<link rel="stylesheet" href="css/bootstrap.min.css" />
<link rel="stylesheet" href="css/reset.css" />
<link rel="stylesheet" href="css/bugInfo.css" />
<script type="text/javascript" src="js/jquery-3.1.1.min.js"></script>
<style>
.msg {
	color: #C9302C;
	font-size: 30px;
	text-decoration: underline;
}

.a {
	font-size: 20px;
	color: black;
	width: 40px;
	height: 40px;
	color: black;
}

.prompt_message {
	width: 400px;
	border: 1px solid #dedede;
	z-index: 1000;
}

.page {
	width: 400px;
 padding-left:20px;
	top: 500px;
	left: 100px;
	position: absolute;
}
</style>
</head>

<body>
	<div>
		<div class="body" style="margin-left: 40px;margin-top: 20px;">

			<form action="bugInfo/buttonSearch" method="post" class="form-inline">
				<!-- id="form1"-->
				<input type="text" name="description" class="form-control"
					id="search" style="width:400px" placeholder="你就随便写点啥就行" />
				<!-- 	<button class="btn btn-danger" style="margin-left: -10px;width:70px;">BUG</button> -->
				<input type="submit" class="btn btn-danger"
					style="margin-left: -10px;width:70px;" value="BUG" />
				<div class="clear"></div>
			</form>

		</div>
		<div class="main">

			<div>

				<div class="float_left left_div">
					<c:forEach items="${list }" var="list">
						<div>
							<a href="bugInfo/searchById?userid=${userInfo.userid }&bugid=${list.bugId}&status=${list.status}&queriesNumber=${list.queriesNumber}" class="msg">${list.description }</a>
						</div>
						<div class="font_size">错误描述:&nbsp;&nbsp;${list.solution }</div>
						<div style="height:30px"></div>
					</c:forEach>
					<div>
						<div class="page">
							<a
								href="bugInfo/buttonSearch?indexPage=1&description=${description }">首页</a>
							<%-- 	<c:if test="${indexPage eq 1 }">
						<a
							href="bugInfo/buttonSearch?indexPage=1&description=${description }">上一页</a>
					</c:if>
					<c:if test="${indexPage ne 1 }">
						<a
							href="bugInfo/buttonSearch?indexPage=${indexPage-1 }&description=${description }">上一页</a>
					</c:if>
					<c:if test="${indexPage eq pageNumber }">
						<a
							href="bugInfo/buttonSearch?indexPage=${ pageNumber}&description=${description }">下一页</a>
					</c:if>
					<c:if test="${indexPage ne 1 }">
						<a
							href="bugInfo/buttonSearch?indexPage=${indexPage+1 }&description=${description }">下一页</a>
						
					</c:if> --%>

							<c:forEach var="i" begin="1" end="${pageNumber }">
								<a
									href="bugInfo/buttonSearch?indexPage=${i }&description=${description }"
									class="a">${i}</a>
							</c:forEach>

							<a
								href="bugInfo/buttonSearch?indexPage=${pageNumber }&description=${description }">尾页</a>

						</div>
					</div>
				</div>
				<div class="float_left right_div">预留广告层</div>

			</div>
			<div class="clear"></div>
		</div>

		<script>
			/* //<!-- var oForm = $("#form1");

			oForm.on("click", function() {
				window.location.href = "html/bugInfo.html";
				//alert("....................");
			})    */
			//搜索框修改事件  根据搜索框的class
			$(function() {

				//keyup键盘移开事件
				//将even(事件)作为参数,就是这个“点击”事件,通过这个even,可以获取到event.target,就是点击的对象等等属性

				$(".prompt_message").css("display", "none");
				$("#search")
						.on(
								"keyup",
								function(even) {
									var masges = $("#search").val();
									if (masges != "") {
										$(".prompt_message").css("display",
												"block");
									} else {
										$(".prompt_message").css("display",
												"none");
									}

									var str = $(this).val().trim();
									//console.log(str+"           "+even.keyCode+"           "+str.length);
									//如果str的长度不为零即为输入中
									if (str.length != 0) {
										$
												.ajax({
													url : "bugInfo/ajaxFind?description="
															+ str,
													success : function(json) {

														/*
														1.清空原有的数据
														2.解析msg
														3.绑定div
														 */
														var obj = JSON
																.parse(json);//解析msg
														$(".prompt_message")
																.empty();//清空原有数据
														for ( var i = 0; i < obj.length; i++) {
															var o = obj[i];
															console.log(o);
															/* $(".prompt_message").append("<div><a href='bugInfo/' style='height:40px;' value='"+o[i]['']+"'>"+o[i]["description"]+"</a></div>"); */

															$(".prompt_message")
																	.append(
																			"<a href='bugInfo/searchBug?description="
																					+ o["description"]
																					+ "' style='height:30px;text-align: left;padding:5px 3px;cursor: pointer;display:block;' class='solution' value="
																					+ o["bugId"]
																					+ ">"
																					+ o['description']
																					+ "</a>");

														}
													}
												})

									}

								})

			});
		</script>
</body>

</html>